require "aio"
include Aio::Helpers

port = "/dev/ttyUSB0"
inpin = 0
outpin = 10

puts "Press Control+C to cancel..."

Aio::Board.new(port) do |board|
	sleep 0.1 until board.ready?
	
	loop do
		if value = board.analogRead(inpin)
			pwm = map(value, 0, 1023, 0, 255)
			board.analogWrite(outpin, pwm)
		end
	end
end
